package com.example.haosiji.maps;

import android.util.Log;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.map.LocationData;
import com.example.haosiji.app.AppInfo;
import com.example.haosiji.app.haosijiApp;

public class locationManager {
	private LocationClient mLocationClient=null;
	protected haosijiApp mApp;
	String address;
	private LocationData mLocData;
	
	
	public  void requestLocaton() {
		mApp = (haosijiApp)AppInfo.mApp;
		mLocationClient=new LocationClient(mApp); 
		mLocData = new LocationData();
		
		mLocationClient.start();
		if ((this.mLocationClient != null)&& (this.mLocationClient.isStarted())){
			mLocationClient.requestLocation();
		}
		
		LocationClientOption option = new LocationClientOption();
		option.setOpenGps(true);
		option.setAddrType("all");
		option.setCoorType("bd09ll");
		option.setScanSpan(5000);
		option.disableCache(false); 
		
        mLocationClient.setLocOption(option);
		
		mLocationClient.registerLocationListener(new BDLocationListenerImpl());
		
	}
	
	
	public class BDLocationListenerImpl implements BDLocationListener {

		public void onReceiveLocation(BDLocation location) {
			if (location == null) {
				return;
			}
			
			AppInfo.latitude = location.getLatitude()+"";
			AppInfo.latitude = location.getLongitude()+"";
			
			
		}

		public void onReceivePoi(BDLocation poiLocation) {

		}

	}
	
	
	
	
	
	
	
	
	
	
	
	
}
